<?php
class Model_DbTable_Pr_Stockmove_Ad extends Zend_Db_Table_Abstract {
	
	protected $_name = 'pr_stockmove_ad';
	protected $_primary  = 'id_job';
	protected $_sequence = false;
	
	public function listAll(){
		
		$rows =$this->fetchAll("1","date_move DESC ");
		if(!$rows) return false;
		return $rows->toArray();			
		
		}
	public function listAllDistinct(){
		$date = Model_DatetimeHelper::adjustMonths('sub', Model_DatetimeHelper::dateToday(), 2);
	
		$select = $this->_db->select();
		$select->distinct()
			->from($this->_name,"id_job")
			->where("`date_move` > '".$date."'")
			->order("date_move DESC");
		$stmt = $this->_db->query($select);
		$result = $stmt->fetchAll();	   
		return $result;
	}	
	public function listPeriodStockLostByShop($idShop,$dateBegin,$dateEnd){
		$whereStr = "`shop_code` = {$idShop} AND `date_move` >= '{$dateBegin}' AND `date_move` <= '{$dateEnd}' AND `staff_name` LIKE 'Parts StockTake'";
		$rows =$this->fetchAll($whereStr,"code_move DESC ");
		if(!$rows) return false;
		return $rows->toArray();
	}
	
	public function listStockMove($idJob){
		$rows =$this->fetchAll("`id_job` like '".$idJob."'");
		if(!$rows) return false;
		return $rows->toArray();
	}
	
}

?>